package com.bifrost.service;

import com.bifrost.annotation.CurrentUser;
import com.bifrost.common.model.ResultModel;
import com.bifrost.entity.*;
import com.bifrost.exception.BonusPointsNotEnoughException;
import com.bifrost.exception.RollbackBonuspointsException;
import com.bifrost.model.AddressModel;
import com.bifrost.model.CustomerModel;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.math.BigInteger;
import java.util.List;

/**
 * @author rangjf
 * @date 2017/10/17
 */
public interface CustomerService {

    public BigInteger getCustomerPoints(Customer customer);

    public Customer findByCustomerPhone(String phone);

    public Customer findByOpenId(String openId);

    public Customer saveCustomer(Customer customer);

    public Customer findCustomer(Long id);

    /**
     * 查询会员默认收货地址
     *
     * @param customer
     * @return
     */
    CustomerAddress getCustomerDefaultAddress(Customer customer);

    /**
     * 获取用户所有收货地址
     *
     * @param customer
     * @return
     */
    List<CustomerAddress> getAllAddress(Customer customer);

    /**
     * 获取用户收货地址详情
     *
     * @param addressId
     * @return
     */
    CustomerAddress getAddrDetail(Long addressId);

    /**
     * 新增收货地址
     *
     * @param customer
     * @param addressModel
     * @return
     */
    CustomerAddress addAddr(Customer customer, AddressModel addressModel);

    /**
     * 更新收货地址
     *
     * @param customer
     * @param addressModel
     * @param addressId
     * @return
     */
    CustomerAddress updateAddr(Customer customer, AddressModel addressModel, String addressId);

    /**
     * 获取用户基本信息
     *
     * @param customerId customerId
     * @return Customer
     */
    public CustomerModel getCustomerModel(Long customerId);

    /**
     * 保存微信基本信息
     *
     * @param customer customer
     * @param request  request
     * @return Customer
     */
    public Customer saveWechatInfo(Customer customer, HttpServletRequest request);

    /**
     * 返回会员基本信息
     *
     * @param customer customer
     * @return Customer
     */
    public CustomerModel getCustomerModelDetail(Customer customer);

    CustomerModel getCustomerDetail(Long customer);

    /**
     * 修改会员基本信息
     *
     * @param model    model
     * @param customer customer
     * @return ResultModel
     */
    public Customer updateCustomerInfo(Customer customer, CustomerModel model);

    /**
     * 绑定会员卡
     * @param customer
     * @param targetNum
     */
     void bindLoyaltyCard(Customer customer, String targetNum);

    /**
     * 奖励会员积分
     * @param order
     * @param loyaltyNo
     */
     void rewardsBonusPoints(Order order,String loyaltyNo);

       /**
     * 回滚订单奖励的积分
     * @param order
     * @param loyaltyNo
     * @throws BonusPointsNotEnoughException
     */
    void rollbackBounsPoints(Order order, String loyaltyNo) throws BonusPointsNotEnoughException;

    /**
     * 退货订单退回相应奖励的积分
     * @param orderReturn
     * @param loyaltyNo
     * @throws BonusPointsNotEnoughException
     */
    void rollbackBounsPoints(OrderReturn orderReturn, String loyaltyNo) throws RollbackBonuspointsException,BonusPointsNotEnoughException;

    /**
     * 根据门店获取默认会员
     * @param storeId
     * @return
     */
     CustomerType findDefaultCustomerType(Long storeId);

    /**
     * 查询门店会员卡对应的会员
     * @param store
     * @param cardNumber
     * @return
     */
    Customer  findCustomer(MerchantStore store, String cardNumber);

    Boolean register(Customer customer, String name, String mobile, String idNum, String verifyCode, int publicid, int ppid, Long stroeId, String userId);

    BigInteger signIn(Customer customer, Long merchantStore, String remark);

    List signInDetail(Customer customer);

    ResultModel getLoyaltyInfo( Long userId);
    ResultModel bind( Long userId,  String mobile,  String idNum,  String verifyCode,  String cardno, int publicid, int ppid);
}
